<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <textarea name="texts" id="" cols="30" rows="10"></textarea>
    <button>提交</button>
    <ul>

    </ul>
    <script>
        var texts = document.querySelector('textarea');
        var btn = document.querySelector('button');
        var ul = document.querySelector('ul');
        btn.onclick = function(){
            if(texts.value == ''){
                alert('');
            }else{
                var li = document.createElement('li');
                li.innerHTML = texts.value + '<a href="javascript:;">删除</a>';
                ul.insertBefore(li,ul.children[0]);
                var a = document.getElementsByTagName('a');
                for(var i = 0; i < a.length; i++){
                    a[i].onclick = function(){
                        /* this.parentNode.parentNode.removeChild(this.parentNode); */
                        ul.removeChild(this.parentNode);
                    }
                }
            }
        }
    </script>
</body>
</html>